.split("1px") into ["1px",1,"px"] in Javascript

Posted by Jay on Stack Overflow See other posts from Stack Overflow or by Jay
Published on 2010-05-19T19:59:21Z Indexed on 2010/05/19 20:10 UTC
Read the original article Hit count: 143

Filed under:
|
|

I'm rubbish at Regular Expressions, really!

What I'd like is to split a string containing a CCS property value into an array of [string,value,unit].

For example: if I supplied the .split() method with 1px it'd return ["1px",1,"px"]. If I were to supply, similarly, 10% it'd return ["10%",10,"%"].

Can this be done?

I appreciate all your help!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex